<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<?php
			define('REL_PATH', '../');
			require REL_PATH . 'includes/setup.php';
			session_start();
			if (isset($_GET['action'])&&$_GET['action'] == 'disconnect')
				disconectAdmin();
			else if (isset($_POST['user']) && isset($_POST['pass']))
				if (!loginAdmin($_POST['user'], $_POST['pass']))
					$message = 'Nom d\'utilisateur ou mot de passe invalide!';
		?>
		<LINK rel="stylesheet" type="text/css" href="<?php echo REL_PATH; ?>style/base.css"/>
		<LINK rel="stylesheet" type="text/css" href="<?php echo REL_PATH; ?>style/admin.css"/>
		<link href="<?php echo REL_PATH; ?>includes/jquery-ui-1.9.2/css/start/jquery-ui-1.9.2.custom.min.css" rel="stylesheet">
		<script src="<?php echo REL_PATH; ?>includes/jquery-ui-1.9.2/js/jquery-1.8.3.min.js"></script>
		<script src="<?php echo REL_PATH; ?>includes/jquery-ui-1.9.2/js/jquery-ui-1.9.2.custom.min.js"></script>
		<script src="<?php echo REL_PATH; ?>style/base.js"></script>
		<title>Netflow - Page admin</title>
	</head>
	<body>
		
		<?php require(I_PATH . "header.php"); ?>
		<div id="container" class="ui-corner-all">
			<?php
				if (isAdminConnected()) {
			?>
			<div id="menu">
				<script>
					$(function() {
						$( "#menu .liste" ).menu();
					});
				</script>
				<ul class="liste">
					<li><a href='?p=catalog'><span class="ui-icon ui-icon-search"></span>Liste des DVD</a></li>
					<li><a href='?p=adddvd'><span class="ui-icon ui-icon-plus"></span>Ajouter un DVD</a></li>
					<li><a href='?p=inspect'><span class="ui-icon ui-icon-tag"></span>Locations</a></li>
					<li><a href='?p=return'><span class="ui-icon ui-icon-plus"></span>Retournez un DVD</a></li>
					<li><a href='?p=editclient'><span class="ui-icon ui-icon-plus"></span>Editer les client</a></li>	
					<li><a href='../templates/auditDownload.php'><span class="ui-icon ui-icon-disk"></span>Audit</a></li>
					<li>-</li>
					<li><a href='?action=disconnect'><span class="ui-icon ui-icon-closethick"></span>Déconnexion</a></li>
				</ul>
			</div>
			<div id="content"><?php
				if (isset($_GET["p"])) {
					if (file_exists(T_PATH . 'admin_' . $_GET['p'] . '.php'))
						require T_PATH . 'admin_' . $_GET['p'] . '.php';
					else
						echo '<font color="red"><b>Erreur 404 - la page administrateur "' . $_GET["p"] . '" est inexistante!</b></font>';
				}
				/*if (isset($_SESSION["admlogin"])) {
					
				} else {
					
				}*/
			?></div>
			<?php
				} else {
			?>
			<div>
				<form method="POST" action="." id="connectForm">
					<?php if (isset($message)) echo '<div class="error">' . $message . '</div>'; ?>
					<table>
						<tr><td><label>Login :</label></td><td><input name="user" <?php if (isset($_POST['user'])) echo 'value="'.$_POST['user'].'" '; ?>/></td></tr>
						<tr><td><label>Mot de passe :</label></td><td><input name="pass" /></td></tr>
						<tr><td colspan="2"><center><input type="submit" /></center></td></tr>
					</table>
				</form>
			</div>
			<?php
				}
			?>
		</div>
		<?php require(I_PATH . "/footer.php"); ?>
	</body>
</html>

